From a04d3fb089c153df3d07523355077bfd817a51e7 Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 4 Oct 2005 14:54:48 +0000 Subject: [PATCH] Add filterdefs to hold protos for filter functions and extern of waypt_head so we can more easily finger the remaining formats that violate the intended 'static-ness' of that symbol. --- arcdist.c | 4 +--- defs.h | 14 -------------- discard.c | 3 ++- duplicate.c | 21 +++++---------------- filter_skeleton.c | 4 ++-- filter_vecs.c | 2 +- filterdefs.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ main.c | 1 + polygon.c | 3 +-- position.c | 2 +- reverse_route.c | 2 +- smplrout.c | 2 +- sort.c | 3 +-- stackfilter.c | 5 ++--- trackfilter.c | 19 ++----------------- 15 files changed, 65 insertions(+), 64 deletions(-) create mode 100644 filterdefs.h diff --git a/arcdist.c b/arcdist.c index 800c45dd4..27499bf1e 100644 --- a/arcdist.c +++ b/arcdist.c @@ -18,14 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */ -#include #include "defs.h" +#include "filterdefs.h" #include "grtcirc.h" #define MYNAME "Arc filter" -extern queue waypt_head; - static double pos_dist; static char *distopt = NULL; static char *arcfileopt = NULL; diff --git a/defs.h b/defs.h index eb77b0940..a89ea7dd7 100644 --- a/defs.h +++ b/defs.h @@ -516,14 +516,6 @@ typedef struct style_vecs { } style_vecs_t; extern style_vecs_t style_list[]; -typedef struct filter_vecs { - filter_init f_init; - filter_process f_process; - filter_deinit f_deinit; - filter_exit f_exit; - arglist_t *args; -} filter_vecs_t; - void waypt_init(void); void route_init(void); void waypt_disp(const waypoint *); @@ -539,12 +531,6 @@ void exit_vecs(void); void disp_formats(int version); void printposn(const double c, int is_lat); -filter_vecs_t * find_filter_vec(char * const, char **); -void free_filter_vec(filter_vecs_t *); -void disp_filters(int version); -void disp_filter_vecs(void); -void exit_filter_vecs(void); - #ifndef DEBUG_MEM void *xcalloc(size_t nmemb, size_t size); void *xmalloc(size_t size); diff --git a/discard.c b/discard.c index 8e7936e18..0973313ba 100644 --- a/discard.c +++ b/discard.c @@ -18,8 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */ -#include + #include "defs.h" +#include "filterdefs.h" static char *hdopopt = NULL; static char *vdopopt = NULL; diff --git a/duplicate.c b/duplicate.c index 5556be28e..31372ec6e 100644 --- a/duplicate.c +++ b/duplicate.c @@ -20,8 +20,7 @@ */ #include #include "defs.h" - -extern queue waypt_head; +#include "filterdefs.h" static char *snopt = NULL; static char *lcopt = NULL; @@ -159,7 +158,8 @@ compare(const void *a, const void *b) } -void + +static void duplicate_process(void) { waypoint * waypointp; @@ -172,7 +172,6 @@ duplicate_process(void) int i, ct = waypt_count(); wpt_ptr *htable, *bh; queue *elem, *tmp; - extern queue waypt_head; htable = (wpt_ptr *) xmalloc(ct * sizeof(*htable)); bh = htable; @@ -250,20 +249,10 @@ duplicate_process(void) } } -void -duplicate_init(const char *args) -{ -} - -void -duplicate_deinit(void) -{ -} - filter_vecs_t duplicate_vecs = { - duplicate_init, + NULL, duplicate_process, - duplicate_deinit, + NULL, NULL, dup_args }; diff --git a/filter_skeleton.c b/filter_skeleton.c index fe6e3b33c..28c58e2e7 100644 --- a/filter_skeleton.c +++ b/filter_skeleton.c @@ -46,7 +46,7 @@ arglist_t filter_skeleton_args[] = { *******************************************************************************/ static void -filter_skeleton_init(const char *args) /* optional */ +filter_skeleton_init(const char *args) /* optional. If not needed, delete and replace entry in vecs with NULL */ { } @@ -60,7 +60,7 @@ filter_skeleton_process(void) /* this procedure must be present in vecs */ } static void -filter_skeleton_deinit(void) /* optional */ +filter_skeleton_deinit(void) /* optional. If not needed, delete and replace entry in vecs with NULL*/ { } diff --git a/filter_vecs.c b/filter_vecs.c index 1aa5ca1b4..3a5568f85 100644 --- a/filter_vecs.c +++ b/filter_vecs.c @@ -19,8 +19,8 @@ */ -#include #include "defs.h" +#include "filterdefs.h" typedef struct { filter_vecs_t *vec; diff --git a/filterdefs.h b/filterdefs.h new file mode 100644 index 000000000..19272c362 --- /dev/null +++ b/filterdefs.h @@ -0,0 +1,44 @@ +/* + Filter definitions. + + Copyright (C) 2005 Robert Lipe, robertlipe@usa.net + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + + + +/* + * Filters can do some things that modules really shouldn't do. + * This is our (weak) attempt to make that distinction. + */ + +extern queue waypt_head; + +typedef struct filter_vecs { + filter_init f_init; + filter_process f_process; + filter_deinit f_deinit; + filter_exit f_exit; + arglist_t *args; +} filter_vecs_t; + +filter_vecs_t * find_filter_vec(char * const, char **); +void free_filter_vec(filter_vecs_t *); +void disp_filters(int version); +void disp_filter_vecs(void); +void exit_filter_vecs(void); + diff --git a/main.c b/main.c index 06e732571..a1b735987 100644 --- a/main.c +++ b/main.c @@ -19,6 +19,7 @@ #include "defs.h" +#include "filterdefs.h" #include "cet.h" #include "cet_util.h" #include diff --git a/polygon.c b/polygon.c index 174eec4c6..c2d9ca5d5 100644 --- a/polygon.c +++ b/polygon.c @@ -19,11 +19,10 @@ */ #include "defs.h" +#include "filterdefs.h" #define MYNAME "Polygon filter" -extern queue waypt_head; - static char *polyfileopt = NULL; static char *exclopt = NULL; diff --git a/position.c b/position.c index 75f0988df..261708c7a 100644 --- a/position.c +++ b/position.c @@ -19,13 +19,13 @@ */ #include "defs.h" +#include "filterdefs.h" #include "grtcirc.h" #ifndef M_PI # define M_PI 3.14159265358979323846 #endif -extern queue waypt_head; static route_head *cur_rte = NULL; static double pos_dist; diff --git a/reverse_route.c b/reverse_route.c index 5ba3a7e32..82b9848eb 100644 --- a/reverse_route.c +++ b/reverse_route.c @@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */ -#include #include "defs.h" +#include "filterdefs.h" #define MYNAME "Route reversal filter" diff --git a/smplrout.c b/smplrout.c index bd9fb8dcd..7688582dc 100644 --- a/smplrout.c +++ b/smplrout.c @@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */ -#include #include "defs.h" +#include "filterdefs.h" #include "grtcirc.h" #define MYNAME "Route simplification filter" diff --git a/sort.c b/sort.c index e91af8317..b0c29c25a 100644 --- a/sort.c +++ b/sort.c @@ -19,8 +19,7 @@ */ #include "defs.h" - -extern queue waypt_head; +#include "filterdefs.h" typedef enum { sm_unknown = 0, diff --git a/stackfilter.c b/stackfilter.c index 494947042..38bfd4854 100644 --- a/stackfilter.c +++ b/stackfilter.c @@ -18,13 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */ -#include + #include "defs.h" +#include "filterdefs.h" #define MYNAME "Stack filter" -extern queue waypt_head; - static char *opt_push = NULL; static char *opt_copy = NULL; static char *opt_pop = NULL; diff --git a/trackfilter.c b/trackfilter.c index acd1bb43b..5797dadb3 100644 --- a/trackfilter.c +++ b/trackfilter.c @@ -28,10 +28,9 @@ 2005-07-29: warning fixes */ -#include -#include #include #include "defs.h" +#include "filterdefs.h" #include "strptime.h" #define MYNAME "trackfilter" @@ -86,20 +85,6 @@ static int track_ct = 0; static int track_pts = 0; static int opt_interval = 0; -/******************************************************************************* -* dummy callbacks for track_disp_all -*******************************************************************************/ - -static void -trackfilter_noop_w(const waypoint *w) -{ -} - -static void -trackfilter_noop_t(const route_head *h) -{ -} - /******************************************************************************* * helpers *******************************************************************************/ @@ -661,7 +646,7 @@ trackfilter_init(const char *args) /* check all tracks for time and order (except merging) */ - track_disp_all(trackfilter_fill_track_list_cb, trackfilter_noop_t, trackfilter_noop_w); + track_disp_all(trackfilter_fill_track_list_cb, NULL, NULL); qsort(track_list, track_ct, sizeof(*track_list), trackfilter_init_qsort_cb); } } -- 2.30.2